package org.sxm.cloud.service.impls;

import org.sxm.cloud.dao.PayDao;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.sxm.cloud.entity.pay.PayEntity;
import org.sxm.cloud.service.IPayService;

import javax.annotation.Resource;
import java.util.Objects;

/**
 * @Description
 * @Author xmSheng
 * @Date 2024/1/30
 */
@Service("payService")
public class PayService implements IPayService {

    private final Logger logger = LoggerFactory.getLogger(PayService.class);
    @Resource
    private PayDao payRepository;

    @Override
    public int pay(PayEntity payEntity) {
        if(Objects.isNull(payEntity))
            return 0;
        payRepository.save(payEntity);
        logger.info("模拟支付成功，生成支付记录id={}",payEntity.getId());
        return 1;
    }
}
